package com.tuozixuan.singleton1;;

/**
 * 双重校验锁机制的同步锁单例模式<br/>
 * 只有在单例对象未实例化的情况下，才能在synchronized代码块前添加附加条件移动线程安全锁<br/>
 * 
 * @see Singleton
 * @see SingletonSync
 * @author tuozixuan
 *
 */
public class SingletonSync3 {

	private static SingletonSync3 instance;

	private SingletonSync3() {
		System.out.println("Something is Instantiated.");
	}

	public static SingletonSync3 getInstance() {
		if (instance == null) {
			synchronized (SingletonSync3.class) {
				if (instance == null) {
					instance = new SingletonSync3();
				}
			}
		}
		return instance;
	}

	public void doSomething() {
		System.out.println("Something is Done.");

	}
}
